package com.hirisun.calendar.filter;

import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;

public class GregorianFestivalFilter extends FestivalFilterBase {

	
	
	public boolean isVocation(Date date) {
		Calendar calendar = Calendar.getInstance();
		
		calendar.setTime(date);
		
		for (Iterator<FestivalDay> iterator = festivals.iterator(); iterator.hasNext();) {
			FestivalDay festival = (FestivalDay) iterator.next();
			
			if(isVocation(calendar, festival)){
				return true;
			}
			
		}		
		return false;
	}
	
	private boolean isVocation(Calendar calendar, FestivalDay festival){
		if((calendar.get(Calendar.MONTH) + 1) == festival.getMonth() &&
			calendar.get(Calendar.DAY_OF_MONTH) == festival.getDay()){			
			return true;
		}
		return false;
	}

}
